//
// File: datawrap.cpp
//
// MATLAB Coder version            : 5.4
// C/C++ source code generated on  : 20-Mar-2025 09:03:00
//

// Include Files
#include "datawrap.h"
#include "calcAR_rtwutil.h"
#include "rt_nonfinite.h"
#include "coder_array.h"

// Function Definitions
//
// Arguments    : const ::coder::array<double, 2U> &x
//                double nfft
//                ::coder::array<double, 2U> &y
// Return Type  : void
//
namespace coder {
void datawrap(const ::coder::array<double, 2U> &x, double nfft,
              ::coder::array<double, 2U> &y)
{
  int b_remainder;
  int nFullPasses;
  int ny_tmp_tmp;
  int offset;
  ny_tmp_tmp = static_cast<int>(nfft);
  y.set_size(1, ny_tmp_tmp);
  for (b_remainder = 0; b_remainder < ny_tmp_tmp; b_remainder++) {
    y[b_remainder] = 0.0;
  }
  nFullPasses = div_s32(x.size(1), static_cast<int>(nfft));
  offset = nFullPasses * static_cast<int>(nfft);
  b_remainder = (x.size(1) - offset) - 1;
  for (int k{0}; k <= b_remainder; k++) {
    y[k] = x[offset + k];
  }
  b_remainder += 2;
  for (int k{b_remainder}; k <= ny_tmp_tmp; k++) {
    y[k - 1] = 0.0;
  }
  for (b_remainder = 0; b_remainder < nFullPasses; b_remainder++) {
    offset = b_remainder * static_cast<int>(nfft);
    for (int k{0}; k < ny_tmp_tmp; k++) {
      y[k] = y[k] + x[offset + k];
    }
  }
}

} // namespace coder

//
// File trailer for datawrap.cpp
//
// [EOF]
//
